package com.ucode.model.cgms.enums;

import cn.hutool.core.util.ArrayUtil;
import com.ucode.tool.base.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * CGMS 支付状态 枚举 1-等待支付 2-支付成功 3-支付关闭 4-支付取消
 *
 * @author ll
 */
@AllArgsConstructor
@Getter
public enum CgmsPayStateEnum implements IntArrayValuable {

    AWAIT(1, "等待支付"),
    SUCCESS(2, "支付成功"),
    CLOSE(3, "支付关闭"),//支付失败
    CANCEL(4, "支付取消"),
    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CgmsPayStateEnum::getState).toArray();

    public static CgmsPayStateEnum get(Integer code) {
        return ArrayUtil.firstMatch(o -> o.getState().equals(code), values());
    }
    /**
     * 状态
     */
    private final Integer state;
    /**
     * 名称
     */
    public final String message;

    public Integer getCode() {
        return state;
    }


    public String getMessage() {
        return message;
    }


    @Override
    public int[] array() {
        return ARRAYS;
    }

}
